package com.study.hadoop.weather;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * 分区
 * @author stephen
 * @create 2019-01-10 21:34
 * @since 1.0.0
 */
public class WeatherPartitioner extends Partitioner<Weather, IntWritable> {

    @Override
    public int getPartition(Weather key, IntWritable value, int numPartitions) {
        // 在此解决数据倾斜
        return key.getYear()%numPartitions ;
    }
}
